package CMinusScanner;

import java.util.ArrayList;

/**
 * @author Adam Plisch and Austin Klob
 * File: TokenContainer.java
 * Created: February 2012
 * Copyright Cedarville University, its Computer Science
 * faculty, and the authors. All rights reserved.
 *
 * Description: This class provides a method to store
 * the tokens that are found in our program. Get and
 * set methods are also added for the management of
 * our data structure.
*/

public class TokenContainer {
    private ArrayList<Token> tokenList = new ArrayList<Token>();
    
    TokenContainer() {
        
    }
    
    public void addToken(Token addedToken) {
        tokenList.add(addedToken);
    }
    
    public Token removeToken(int index) {
        return tokenList.remove(index);
    }
    
    public int getSize() {
        return tokenList.size();
    }
    
    public void printTokens() {
        for (int i = 0; i < tokenList.size(); i++) {
            System.out.println("\n Token Type: " + tokenList.get(i).getType());
            if (tokenList.get(i).getType() != null){
                System.out.print(" Data: ");
                System.out.println(tokenList.get(i).getData());
            }
        }
    }
    
}